package com;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
/**
 * 测试json
 * @author fengbo
 *
 */
public class JsonAction extends DispatchAction {

	/**
	 * 
	 */
	public ActionForward getData(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		Map map = new HashMap(); 
		map.put("age", 22); 
		map.put("name", "sherry"); 

		Map data = new HashMap(); 
		data.put("data", map); 
		data.put("success", true); 
		
		JSONObject json = new JSONObject();
		json.put("a", "a");
		
		
		JSONObject.fromObject(data).write(response.getWriter()); 


		return null;
	}
	public static void main(String [] args){
		List<String> list = new ArrayList();
		for(int i=0;i<1000;i++){
			list.add(i+"");
		}
		
		list.remove(4);
		for(int i = 0;i<list.size();i++){
			System.out.print(list.get(i)+"\t");
		}

	}
	
}
